/**
 * 
 */
package com.sci.web.action.eninfomanager;

import javax.annotation.Resource;

import com.sci.web.action.util.BaseAction;
import com.sci.web.bean.Enterprise_Base;
import com.sci.web.dao.EnterpriseInfoManageDao;

/**
 * @author  BaiFuyou
 * @date: Oct 12, 2011 3:03:30 PM
 * 
 * 
 * 企业信息更改（qyxxgg.js）
 * 
 * 根据ID获取企业信息
 * 
 */
public class GetEnterpriseInfoAction extends BaseAction {

	/**
	 * 
	 */
	private static final long serialVersionUID = 434911889604307715L;
	/**
	 * 用户ID
	 */
	private int id;
	@Resource
	private EnterpriseInfoManageDao enterpriseInfoManageDao;
	/**
	 * @return the id
	 */
	public int getId() {
		return id;
	}
	/**
	 * @param id the id to set
	 */
	public void setId(int id) {
		this.id = id;
	}
	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub
		super.setContentType(super.JSON);
//		System.out.println(id+"==id");
		
		Enterprise_Base eb = enterpriseInfoManageDao.getEnterprise_BaseInfoByUserId(id);
		StringBuffer sb = new StringBuffer("");
		/**
		 * 如果正在审核
		 */
		if(enterpriseInfoManageDao.isEnterpriseInfoChecking(id)){
			sb.append("{'id':'"+"',");
			sb.append("'enterprise_city':'"+"',");
			sb.append("'enterprise_address':'"+"',");
			sb.append("'enterprise_updatestatus':'"+"1',");
			sb.append("'enterprise_post_code':'"+"',");
			sb.append("'enterprise_corporate_code':'"+"',");
			sb.append("'enterprise_corporateRepresentative':'"+"',");
			sb.append("'enterprise_telephone':'"+"',");
			sb.append("'enterprise_person_incharge':'"+"',");
			sb.append("'enterprise_phone_incharge':'"+"',");
			sb.append("'enterprise_eco_type':'"+"',");
			sb.append("'enterprise_org_type':'"+"',");
			sb.append("'enterprise_largest_sharehoder':'"+"',");
			sb.append("'enterprise_largest_share':'"+"',");
			sb.append("'enterprise_listed_type':'"+"',");
			sb.append("'enterprise_science_type':'"+"',");
			sb.append("'enterprise_industry_code':'"+"',");
			sb.append("'enterprise_credit_degree':'"+"',");
			sb.append("'enterprise_field_closeness':'"+"',");
			sb.append("'enterprise_business_field':'"+"',");
			sb.append("'enterprise_major_business':'"+"',");
			sb.append("'enterprise_staff_count':'"+"',");
			sb.append("'enterprise_staff_collegedegree_count':'"+"',");
			sb.append("'enterprise_research_staff_count':'"+"',");
			sb.append("'enterprise_senior_technician_count':'"+"'}");
			
			outPrint(sb.toString());
			return "json";
		}
		
		if(eb != null){
			sb.append("{'id':'"+eb.getId()+"',");
			sb.append("'enterprise_name':'"+eb.getEnterprise_name()+"',");
			sb.append("'enterprise_city':'"+eb.getEnterprise_city()+"',");
			sb.append("'enterprise_updatestatus':'"+"0',");
			sb.append("'enterprise_address':'"+eb.getEnterprise_address()+"',");
			sb.append("'enterprise_post_code':'"+eb.getEnterprise_postcode()+"',");
			sb.append("'enterprise_corporate_code':'"+eb.getEnterprise_corporate_code()+"',");
			sb.append("'enterprise_corporateRepresentative':'"+eb.getEnterprise_corporateRepresentative()+"',");
			sb.append("'enterprise_telephone':'"+eb.getEnterprise_telephone()+"',");
			sb.append("'enterprise_person_incharge':'"+eb.getEnterprise_person_incharge()+"',");
			sb.append("'enterprise_phone_incharge':'"+eb.getEnterprise_phone_incharge()+"',");
			sb.append("'enterprise_eco_type':'"+eb.getEnterprise_eco_type()+"',");
			sb.append("'enterprise_org_type':'"+eb.getEnterprise_org_type()+"',");
			sb.append("'enterprise_largest_sharehoder':'"+eb.getEnterprise_largest_sharehoder()+"',");
			sb.append("'enterprise_largest_share':'"+eb.getEnterprise_largest_share()+"',");
			sb.append("'enterprise_listed_type':'"+eb.getEnterprise_listed_type()+"',");
			sb.append("'enterprise_science_type':'"+eb.getEnterprise_science_type()+"',");
			sb.append("'enterprise_industry_code':'"+eb.getEnterprise_industry_code()+"',");
			sb.append("'enterprise_credit_degree':'"+eb.getEnterprise_credit_degree()+"',");
			sb.append("'enterprise_field_closeness':'"+eb.getEnterprise_field_closeness()+"',");
			sb.append("'enterprise_business_field':'"+eb.getEnterprise_business_field()+"',");
			sb.append("'enterprise_major_business':'"+eb.getEnterprise_major_business()+"',");
			sb.append("'enterprise_staff_count':'"+eb.getEnterprise_staff_count()+"',");
			sb.append("'enterprise_staff_collegedegree_count':'"+eb.getEnterprise_staff_collegedegree_count()+"',");
			sb.append("'enterprise_research_staff_count':'"+eb.getEnterprise_research_staff_count()+"',");
			sb.append("'enterprise_senior_technician_count':'"+eb.getEnterprise_senior_technician_count()+"'}");	
		}else{
			sb.append("{'id':'"+"',");
			sb.append("'enterprise_name':'"+"',");
			sb.append("'enterprise_city':'"+"',");
			sb.append("'enterprise_address':'"+"',");
			sb.append("'enterprise_post_code':'"+"',");
			sb.append("'enterprise_corporate_code':'"+"',");
			sb.append("'enterprise_updatestatus':'"+"0',");
			sb.append("'enterprise_corporateRepresentative':'"+"',");
			sb.append("'enterprise_telephone':'"+"',");
			sb.append("'enterprise_person_incharge':'"+"',");
			sb.append("'enterprise_phone_incharge':'"+"',");
			sb.append("'enterprise_eco_type':'"+"',");
			sb.append("'enterprise_org_type':'"+"',");
			sb.append("'enterprise_largest_sharehoder':'"+"',");
			sb.append("'enterprise_largest_share':'"+"',");
			sb.append("'enterprise_listed_type':'"+"',");
			sb.append("'enterprise_science_type':'"+"',");
			sb.append("'enterprise_industry_code':'"+"',");
			sb.append("'enterprise_credit_degree':'"+"',");
			sb.append("'enterprise_field_closeness':'"+"',");
			sb.append("'enterprise_business_field':'"+"',");
			sb.append("'enterprise_major_business':'"+"',");
			sb.append("'enterprise_staff_count':'"+"',");
			sb.append("'enterprise_staff_collegedegree_count':'"+"',");
			sb.append("'enterprise_research_staff_count':'"+"',");
			sb.append("'enterprise_senior_technician_count':'"+"'}");
		}
		System.out.println(sb.toString());
		outPrint(sb.toString());
		return "json";
	}

}
